#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

#define BUFFER_IN_GB 1

int main(int argc, char* argv[]) {
  if (argc == 2 && strcmp("--cmd", argv[1]) == 0) {
    cout<<"ll --block-size=KB QSSI14/out/target/product/qssi/*img UM.9.14/out/target/product/lahaina/*img"<<endl;
    return 0;
  }
  if (argc != 6) {
    cout<<"需要输入5个img的大小（KB）."<<endl;
    return -1;
  }

  long sumInKb = 0;
  long superSize = 0;            // 单位是Byte
  long dynamicSuperSize = 0;     // 单位是Byte
  long qfilSuperSizeKB = 0;

  for(int i = 1; i < argc;i++) {
    //printf("arg [%d] = %s\n", i, argv[i]);
    //cout<<"arg ["<<i<<"] = "<<argv[i]<<endl;
    long kb = atol(argv[i]);
    //cout<<"kb(long) = "<<kb<<endl;
    sumInKb += kb;
  }
  // align 4KB
  long yushu = sumInKb % 4;
  if (yushu != 0) {
    sumInKb += (4 - yushu);
  }
  // add 1G buffer
  sumInKb += BUFFER_IN_GB * 1024 * 1024;

  superSize = sumInKb * 1024;
  qfilSuperSizeKB = sumInKb;
  dynamicSuperSize = (sumInKb - 4 * 1024 /* 4MB */) /* KB*/ * 1024;

  cout<<"BOARD_SUPER_PARTITION_SIZE = "<<superSize<<endl;
  cout<<"BOARD_QTI_DYNAMIC_PARTITIONS_SIZE = "<<dynamicSuperSize<<endl;
  cout<<"qfil super_size_in_kb = "<<qfilSuperSizeKB<<endl;
  return 0;
}
